<template>
	<view class="course">
		<view v-for="(item,index) in courses" :key="index">
			<media-item :options="item" @click="goDetail(item.id)"></media-item>
		</view>
	</view>
</template>

<script>
    import mediaItem from './news-item-1.nvue';
	import { getCourseList } from '@/api';
	
	export default {
		components: {
			mediaItem
		}, 
		data() {
			return {
				courses: []
			}
		}, 
		methods: {
			getCoursesList() {
				uni.showLoading({
					title: '加载中...'
				})
				
				
				// getOrderList({
				// 	userId: uni.getStorageSync('openid'),
				// 	statue: 3
				// }).then(res => {
				// 	uni.hideLoading();
				// 	this.courses = res.oData;
				// })//返回拼团成功的课程信息
				
				
				getCourseList({
					type: 1,
					userId: uni.getStorageSync('openid')
				}).then(res => {
					console.log(res.oData);
					uni.hideLoading();
					this.courses = res.oData;
				})
				
				
				
			},
			goDetail(id) {
				uni.navigateTo({
					url: '../myDetail/myDetail?id=' + id
				})
			}
		},
		mounted() {
			this.getCoursesList();
		}
	}
</script>

<style>

</style>
